
<?php
	include('includes/header.php');
	include('includes/sidebar-admin.php');
?>
<?php
  if(isset($_POST['btnSubmit']))
  {
 		
  		$name = $_POST['txtName'];
  		$cat = $_POST['slDM'];

  		$q = "INSERT INTO chuyen_muc (ten_chuyen_muc, id_chuyen_muc_me) VALUES ('$name', $cat)";
  		mysql_query($q) or die (mysql_error());
  		if(mysql_affected_rows() > 0)
  		{
  			header("Location: danh-muc.php");
  		}
  		else {
  			$mes .= "Xin vui lòng kiểm tra thông tin vừa nhập"; 
  		}
  }
?>
	<div class="content">
		<div class="contenttitle">
            <h2 class="form"><span>Add Category</span></h2>
        </div>
        <div class="form-add">
        	<form class="stdform" method="POST" action="">
                    	<p>
                        	<label>Tên danh mục: </label>
                            <span class="field"><input type="text" name="txtName" id="firstname" class="input-medium"></span>
                        </p>
                        
                        <p>
                        	<label>Thuộc danh mục</label>
                            <span class="field">
                            <select name="slDM" id="selection">
                            	<option value="0">Danh mục top</option>
                            </select>
                            </span>
                        </p>
                        
                        <br>
                        
                        <p class="stdformbutton">
                        	<button type="submit" name="btnSubmit" class="submit radius2">Add Category</button>
                        	<?php
                        		if(isset($mes)) echo $mes;
                        	?>
                        </p>
                    </form>
        </div>
	</div>
<?php
    include('includes/footer.php');
?>